{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "$\\newcommand{\\Vt}[1]{\\mathbf{#1}}$\n",
      "$\\newcommand{\\Mt}[1]{\\mathbf{#1}}$\n",
      "$\\newcommand{\\vtA}{\\Vt{A}}$\n",
      "$\\newcommand{\\vtB}{\\Vt{B}}$\n",
      "$\\newcommand{\\vtC}{\\Vt{C}}$\n",
      "$\\newcommand{\\vtD}{\\Vt{D}}$\n",
      "$\\newcommand{\\vtE}{\\Vt{E}}$\n",
      "$\\newcommand{\\vtF}{\\Vt{F}}$\n",
      "$\\newcommand{\\vtG}{\\Vt{G}}$\n",
      "$\\newcommand{\\vtH}{\\Vt{H}}$\n",
      "$\\newcommand{\\vtI}{\\Vt{I}}$\n",
      "$\\newcommand{\\vtJ}{\\Vt{J}}$\n",
      "$\\newcommand{\\vtK}{\\Vt{K}}$\n",
      "$\\newcommand{\\vtL}{\\Vt{L}}$\n",
      "$\\newcommand{\\vtM}{\\Vt{M}}$\n",
      "$\\newcommand{\\vtN}{\\Vt{N}}$\n",
      "$\\newcommand{\\vtO}{\\Vt{P}}$\n",
      "$\\newcommand{\\vtP}{\\Vt{P}}$\n",
      "$\\newcommand{\\vtQ}{\\Vt{Q}}$\n",
      "$\\newcommand{\\vtR}{\\Vt{R}}$\n",
      "$\\newcommand{\\vtS}{\\Vt{S}}$\n",
      "$\\newcommand{\\vtT}{\\Vt{T}}$\n",
      "$\\newcommand{\\vtU}{\\Vt{U}}$\n",
      "$\\newcommand{\\vtV}{\\Vt{V}}$\n",
      "$\\newcommand{\\vtW}{\\Vt{W}}$\n",
      "$\\newcommand{\\vtX}{\\Vt{X}}$\n",
      "$\\newcommand{\\vtY}{\\Vt{Y}}$\n",
      "$\\newcommand{\\vtZ}{\\Vt{Z}}$\n",
      "$\\newcommand{\\mtA}{\\Mt{A}}$\n",
      "$\\newcommand{\\mtB}{\\Mt{B}}$\n",
      "$\\newcommand{\\mtC}{\\Mt{C}}$\n",
      "$\\newcommand{\\mtD}{\\Mt{D}}$\n",
      "$\\newcommand{\\mtE}{\\Mt{E}}$\n",
      "$\\newcommand{\\mtF}{\\Mt{F}}$\n",
      "$\\newcommand{\\mtG}{\\Mt{G}}$\n",
      "$\\newcommand{\\mtH}{\\Mt{H}}$\n",
      "$\\newcommand{\\mtI}{\\Mt{I}}$\n",
      "$\\newcommand{\\mtJ}{\\Mt{J}}$\n",
      "$\\newcommand{\\mtK}{\\Mt{K}}$\n",
      "$\\newcommand{\\mtL}{\\Mt{L}}$\n",
      "$\\newcommand{\\mtM}{\\Mt{M}}$\n",
      "$\\newcommand{\\mtN}{\\Mt{N}}$\n",
      "$\\newcommand{\\mtO}{\\Mt{P}}$\n",
      "$\\newcommand{\\mtP}{\\Mt{P}}$\n",
      "$\\newcommand{\\mtQ}{\\Mt{Q}}$\n",
      "$\\newcommand{\\mtR}{\\Mt{R}}$\n",
      "$\\newcommand{\\mtS}{\\Mt{S}}$\n",
      "$\\newcommand{\\mtT}{\\Mt{T}}$\n",
      "$\\newcommand{\\mtU}{\\Mt{U}}$\n",
      "$\\newcommand{\\mtV}{\\Mt{V}}$\n",
      "$\\newcommand{\\mtW}{\\Mt{W}}$\n",
      "$\\newcommand{\\mtX}{\\Mt{X}}$\n",
      "$\\newcommand{\\mtY}{\\Mt{Y}}$\n",
      "$\\newcommand{\\mtZ}{\\Mt{Z}}$"
     ]
    },
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Interference Alignment Algorithms"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "This notebook illustrates some Interference Alignment algorithms.\n",
      "\n",
      "The channel model used is the $K$-user MIMO IC channel, where we have $K$ pairs of transmitters and receivers and each transmitter sends useful information only to its intended receiver, while interfering with the other receivers. This is shown in the figure below"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<center><img src=\"files/figs/mimo_ic_channel.png\" /></center>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "The received signal at the $i$-th receiver is given by\n",
      "\n",
      "$$\\vtY_i = \\mtH_{ii}\\mtP_i\\vtX_i + \\sum_{j=1,i \\neq j}^{K}\\mtH_{ij}\\mtP_j \\vtX_j + \\vtN_i$$"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Max SINR Algorithm"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# xxxxxxxxxx Add the parent folder to the python path. xxxxxxxxxxxxxxxxxxxx\n",
      "import sys\n",
      "import os\n",
      "parent_dir = os.path.abspath(\"../\")\n",
      "sys.path.append(parent_dir)\n",
      "# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
      "\n",
      "# Imports\n",
      "import numpy as np\n",
      "from pyphysim.ia.ia import MaxSinrIASolver\n",
      "from pyphysim.comm.channels import MultiUserChannelMatrix"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Parameters\n",
      "K = 3\n",
      "Nt = np.ones(K, dtype=int) * 2\n",
      "Nr = np.ones(K, dtype=int) * 2\n",
      "Ns = np.ones(K, dtype=int) * 1\n",
      "\n",
      "# Transmit power of all users\n",
      "#P = np.array([1.2, 1.5, 0.9])\n",
      "P = np.array([1.0, 1.0, 1.0])\n",
      "\n",
      "multiUserChannel = MultiUserChannelMatrix()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "iasolver = MaxSinrIASolver(multiUserChannel)\n",
      "# xxxxx Debug xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
      "np.random.seed(42)  # Used in the generation of the random precoder\n",
      "iasolver._multiUserChannel.set_channel_seed(324)\n",
      "# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "multiUserChannel.randomize(Nr, Nt, K)\n",
      "iasolver.randomizeF(Ns, P)\n",
      "iasolver._W = iasolver._calc_Uk_all_k()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 4
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "H00 = multiUserChannel.H[0,0]\n",
      "H01 = multiUserChannel.H[0,1]\n",
      "H02 = multiUserChannel.H[0,2]\n",
      "H10 = multiUserChannel.H[1,0]\n",
      "H11 = multiUserChannel.H[1,1]\n",
      "H12 = multiUserChannel.H[1,2]\n",
      "H20 = multiUserChannel.H[2,0]\n",
      "H21 = multiUserChannel.H[2,1]\n",
      "H22 = multiUserChannel.H[2,2]\n",
      "\n",
      "print \"H00:\\n{0}\".format(H00)\n",
      "print \"H01:\\n{0}\".format(H01)\n",
      "print \"H02:\\n{0}\".format(H02)\n",
      "print \"H10:\\n{0}\".format(H10)\n",
      "print \"H11:\\n{0}\".format(H11)\n",
      "print \"H12:\\n{0}\".format(H12)\n",
      "print \"H20:\\n{0}\".format(H20)\n",
      "print \"H21:\\n{0}\".format(H21)\n",
      "print \"H22:\\n{0}\".format(H22)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "H00:\n",
        "[[ 0.01608358-0.28801973j -0.50580390+0.46957611j]\n",
        " [ 0.39462287+0.62481233j -1.02069290-1.5030812j ]]\n",
        "H01:\n",
        "[[-0.11873262+1.42888543j -0.31994329+0.13836513j]\n",
        " [ 0.57738181+0.41599236j -0.78665621-0.14339029j]]\n",
        "H02:\n",
        "[[ 0.49340765-0.25458154j  0.03147854+0.43807291j]\n",
        " [ 1.18848527-0.104588j   -0.17561667+0.74935185j]]\n",
        "H10:\n",
        "[[-0.42117955+0.48372503j  0.04705041-0.09973857j]\n",
        " [ 0.92956390+0.09824229j  0.08322531-0.67695677j]]\n",
        "H11:\n",
        "[[-1.34734628-0.53649153j -0.38577536-0.48610577j]\n",
        " [-0.91668658+0.95406676j -0.22285468-0.53978479j]]\n",
        "H12:\n",
        "[[ 0.32888506-0.76865339j  0.72286753-1.29639442j]\n",
        " [ 0.41708429-0.7573189j  -0.61649953-0.27770005j]]\n",
        "H20:\n",
        "[[ 0.23383923+0.20593993j  0.86344260-0.43217091j]\n",
        " [ 1.14296838-1.03600672j  1.20329661+0.51232803j]]\n",
        "H21:\n",
        "[[ 0.11485867-0.58304759j -0.07661408-0.27170194j]\n",
        " [ 1.51098154-0.52919436j  1.31794940-0.65805912j]]\n",
        "H22:\n",
        "[[-0.51944144+0.16765058j -0.27394494-1.16611525j]\n",
        " [ 0.15608834-1.16981583j  0.97095685-0.67274147j]]\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "source": [
      "Step 0"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Different precoders: Fkl is column vector\n",
      "F00 = iasolver.F[0][:, 0:1]\n",
      "F10 = iasolver.F[1][:, 0:1]\n",
      "F20 = iasolver.F[2][:, 0:1]\n",
      "print \"F00:\\n{0}\".format(F00)\n",
      "print \"F10:\\n{0}\".format(F10)\n",
      "print \"F20:\\n{0}\".format(F20)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "F00:\n",
        "[[ 0.28654116+0.37363426j]\n",
        " [-0.07976099+0.87859535j]]\n",
        "F10:\n",
        "[[-0.13104903+0.8838408j ]\n",
        " [-0.13103984+0.42951154j]]\n",
        "F20:\n",
        "[[-0.48257617-0.47635045j]\n",
        " [ 0.55770145-0.47872704j]]\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Lets calculate the covariance matrices $\\mtB^{[kl]}$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Bkl for the different k and l\n",
      "# k=0, l=0\n",
      "second_part00 = np.dot(np.dot(np.dot(H00, F00), F00.transpose().conjugate()), H00.transpose().conjugate())\n",
      "first_part00 = np.dot(np.dot(np.dot(H00, F00), F00.transpose().conjugate()), H00.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(H01, F10), F10.transpose().conjugate()), H01.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(H02, F20), F20.transpose().conjugate()), H02.transpose().conjugate())\n",
      "\n",
      "B00 = first_part00 - second_part00 + np.eye(Nr[0])\n",
      "print \"B00:\\n{0}\".format(B00)\n",
      "print\n",
      "\n",
      "# k=1, l=0\n",
      "second_part10 = np.dot(np.dot(np.dot(H11, F10), F10.transpose().conjugate()), H11.transpose().conjugate())\n",
      "first_part10 = np.dot(np.dot(np.dot(H10, F00), F00.transpose().conjugate()), H10.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(H11, F10), F10.transpose().conjugate()), H11.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(H12, F20), F20.transpose().conjugate()), H12.transpose().conjugate())\n",
      "B10 = first_part10 - second_part10 + np.eye(Nr[0])\n",
      "print \"B10:\\n{0}\".format(B10)\n",
      "print\n",
      "\n",
      "# k=2, l=0\n",
      "second_part20 = np.dot(np.dot(np.dot(H22, F20), F20.transpose().conjugate()), H22.transpose().conjugate())\n",
      "first_part20 = np.dot(np.dot(np.dot(H20, F00), F00.transpose().conjugate()), H20.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(H21, F10), F10.transpose().conjugate()), H21.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(H22, F20), F20.transpose().conjugate()), H22.transpose().conjugate())\n",
      "B20 = first_part20 - second_part20 + np.eye(Nr[0])\n",
      "print \"B20:\\n{0}\".format(B20)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "B00:\n",
        "[[ 2.83148088 -1.68010679e-16j  0.33755361 +2.53439312e-01j]\n",
        " [ 0.33755361 -2.53439312e-01j  1.22798217 +6.24500451e-17j]]\n",
        "\n",
        "B10:\n",
        "[[ 2.32998211 -1.07552856e-16j  0.34611099 +1.25018065e+00j]\n",
        " [ 0.34611099 -1.25018065e+00j  3.09472296 +1.38777878e-17j]]\n",
        "\n",
        "B20:\n",
        "[[ 2.39889878 -3.81639165e-17j  1.73744062 -1.40795424e+00j]\n",
        " [ 1.73744062 +1.40795424e+00j  6.71883808 -2.22044605e-16j]]\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Lets calculate the combining vectors $\\mtU^{[kl]}_{\\star l}$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Uk_all_K = iasolver._calc_Uk_all_k()\n",
      "\n",
      "# k = 0, l=0\n",
      "U00 = np.dot(np.dot(np.linalg.inv(B00), H00), F00)\n",
      "U00 = U00/np.linalg.norm(U00, 'fro')\n",
      "print \"U00:\\n{0}\".format(U00)\n",
      "print \"Uk_all_K[0]:\\n{0}\".format(Uk_all_K[0])\n",
      "print\n",
      "\n",
      "U10 = np.dot(np.dot(np.linalg.inv(B10), H11), F10)\n",
      "U10 = U10/np.linalg.norm(U10, 'fro')\n",
      "print \"U10:\\n{0}\".format(U10)\n",
      "print \"Uk_all_K[1]:\\n{0}\".format(Uk_all_K[1])\n",
      "print\n",
      "\n",
      "U20 = np.dot(np.dot(np.linalg.inv(B20), H22), F20)\n",
      "U20 = U20/np.linalg.norm(U20, 'fro')\n",
      "print \"U20:\\n{0}\".format(U20)\n",
      "print \"Uk_all_K[2]:\\n{0}\".format(Uk_all_K[2])\n",
      "print"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "U00:\n",
        "[[-0.20584350-0.20403706j]\n",
        " [ 0.91702222-0.27398464j]]\n",
        "Uk_all_K[0]:\n",
        "[[-0.21999136-0.10892635j]\n",
        " [ 0.93527733-0.2549415j ]]\n",
        "\n",
        "U10:\n",
        "[[ 0.51510901-0.83342555j]\n",
        " [ 0.03967541-0.19618974j]]\n",
        "Uk_all_K[1]:\n",
        "[[ 0.43764353-0.83442539j]\n",
        " [ 0.30269154+0.14345815j]]\n",
        "\n",
        "U20:\n",
        "[[-0.47352179-0.82427513j]\n",
        " [-0.29071615+0.1087738j ]]\n",
        "Uk_all_K[2]:\n",
        "[[-0.41174665-0.84878259j]\n",
        " [-0.17624769+0.28101523j]]\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Now lets reverse the comunication"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# The precoders correspond to the combining vectors\n",
      "Fr00 = U00\n",
      "Fr10 = U10\n",
      "Fr20 = U20\n",
      "\n",
      "# The channel Hkl correspods to Hlk^H\n",
      "Hr00 = H00.transpose().conjugate()\n",
      "Hr01 = H10.transpose().conjugate()\n",
      "Hr02 = H20.transpose().conjugate()\n",
      "Hr10 = H01.transpose().conjugate()\n",
      "Hr11 = H11.transpose().conjugate()\n",
      "Hr12 = H21.transpose().conjugate()\n",
      "Hr20 = H02.transpose().conjugate()\n",
      "Hr21 = H12.transpose().conjugate()\n",
      "Hr22 = H22.transpose().conjugate()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 9
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Lets calculate the covariance matrices in the reversed network"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Bkl for the different k and l\n",
      "# k=0, l=0\n",
      "second_part_r_00 = np.dot(np.dot(np.dot(Hr00, Fr00), Fr00.transpose().conjugate()), Hr00.transpose().conjugate())\n",
      "first_part_r_00 = np.dot(np.dot(np.dot(Hr00, Fr00), Fr00.transpose().conjugate()), Hr00.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(Hr01, Fr10), Fr10.transpose().conjugate()), Hr01.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(Hr02, Fr20), Fr20.transpose().conjugate()), Hr02.transpose().conjugate())\n",
      "\n",
      "Br00 = first_part_r_00 - second_part_r_00 + np.eye(Nr[0])\n",
      "print \"Br00:\\n{0}\".format(Br00)\n",
      "print\n",
      "\n",
      "# k=1, l=0\n",
      "second_part_r_10 = np.dot(np.dot(np.dot(Hr11, Fr10), Fr10.transpose().conjugate()), Hr11.transpose().conjugate())\n",
      "first_part_r_10 = np.dot(np.dot(np.dot(Hr10, Fr00), Fr00.transpose().conjugate()), Hr10.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(Hr11, Fr10), Fr10.transpose().conjugate()), Hr11.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(Hr12, Fr20), Fr20.transpose().conjugate()), Hr12.transpose().conjugate())\n",
      "Br10 = first_part_r_10 - second_part_r_10 + np.eye(Nr[0])\n",
      "print \"Br10:\\n{0}\".format(Br10)\n",
      "print\n",
      "\n",
      "# k=2, l=0\n",
      "second_part_r_20 = np.dot(np.dot(np.dot(Hr22, Fr20), Fr20.transpose().conjugate()), Hr22.transpose().conjugate())\n",
      "first_part_r_20 = np.dot(np.dot(np.dot(Hr20, Fr00), Fr00.transpose().conjugate()), Hr20.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(Hr21, Fr10), Fr10.transpose().conjugate()), Hr21.transpose().conjugate()) + \\\n",
      "    np.dot(np.dot(np.dot(Hr22, Fr20), Fr20.transpose().conjugate()), Hr22.transpose().conjugate())\n",
      "Br20 = first_part_r_20 - second_part_r_20 + np.eye(Nr[0])\n",
      "print \"Br20:\\n{0}\".format(Br20)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Br00:\n",
        "[[ 1.97043611 -6.93889390e-17j  0.27611275 -3.74309636e-01j]\n",
        " [ 0.27611275 +3.74309636e-01j  1.58517760 -5.98479599e-17j]]\n",
        "\n",
        "Br10:\n",
        "[[ 1.20576922 -2.77555756e-17j -0.13857722 +1.39275408e-01j]\n",
        " [-0.13857722 -1.39275408e-01j  1.66033061 +1.38777878e-17j]]\n",
        "\n",
        "Br20:\n",
        "[[ 3.24491561 -6.93889390e-17j  1.17830631 +6.81990213e-01j]\n",
        " [ 1.17830631 -6.81990213e-01j  3.75970701 -1.38777878e-16j]]\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Calculate the combining vectors in the reverse network"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "Urk_all_K = iasolver._calc_Uk_all_k_rev()\n",
      "\n",
      "# k = 0, l=0\n",
      "Ur00 = np.dot(np.dot(np.linalg.inv(Br00), Hr00), Fr00)\n",
      "Ur00 = Ur00/np.linalg.norm(Ur00, 'fro')\n",
      "print \"Ur00:\\n{0}\".format(Ur00)\n",
      "print \"Urk_all_K[0]:\\n{0}\".format(Urk_all_K[0])\n",
      "print\n",
      "\n",
      "Ur10 = np.dot(np.dot(np.linalg.inv(Br10), Hr11), Fr10)\n",
      "Ur10 = Ur10/np.linalg.norm(Ur10, 'fro')\n",
      "print \"Ur10:\\n{0}\".format(Ur10)\n",
      "print \"Urk_all_K[1]:\\n{0}\".format(Urk_all_K[1])\n",
      "print\n",
      "\n",
      "Ur20 = np.dot(np.dot(np.linalg.inv(Br20), Hr22), Fr20)\n",
      "Ur20 = Ur20/np.linalg.norm(Ur20, 'fro')\n",
      "print \"Ur20:\\n{0}\".format(Ur20)\n",
      "print \"Urk_all_K[2]:\\n{0}\".format(Urk_all_K[2])\n",
      "print"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Ur00:\n",
        "[[-0.03669770-0.42489184j]\n",
        " [-0.30720274+0.85073302j]]\n",
        "Urk_all_K[0]:\n",
        "[[-0.27275417-0.31606511j]\n",
        " [-0.38410481+0.82351169j]]\n",
        "\n",
        "Ur10:\n",
        "[[-0.22912719+0.91781329j]\n",
        " [ 0.03032394+0.32280018j]]\n",
        "Urk_all_K[1]:\n",
        "[[-0.16985253+0.89471661j]\n",
        " [-0.08443462+0.40435517j]]\n",
        "\n",
        "Ur20:\n",
        "[[-0.43086990+0.21088222j]\n",
        " [ 0.72220855-0.49829171j]]\n",
        "Urk_all_K[2]:\n",
        "[[-0.61046437-0.08501988j]\n",
        " [ 0.67625799-0.40346005j]]\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Reverse the comunication again"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "iasolver._F = Urk_all_K\n",
      "print \"F00:\\n{0}\".format(iasolver.F[0])\n",
      "print \"F10:\\n{0}\".format(iasolver.F[1])\n",
      "print \"F20:\\n{0}\".format(iasolver.F[2])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "F00:\n",
        "[[-0.27275417-0.31606511j]\n",
        " [-0.38410481+0.82351169j]]\n",
        "F10:\n",
        "[[-0.16985253+0.89471661j]\n",
        " [-0.08443462+0.40435517j]]\n",
        "F20:\n",
        "[[-0.61046437-0.08501988j]\n",
        " [ 0.67625799-0.40346005j]]\n"
       ]
      }
     ],
     "prompt_number": 12
    }
   ],
   "metadata": {}
  }
 ]
}